import 'package:architecture/log.dart';
import 'package:architecture/os_size.dart';
import 'package:device_info_plus/device_info_plus.dart';

/// 系统版本
Future<String> getDeviceVersion() async {
  DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
  String deviceVersion = '';
  if (isAndroid()) {
    AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
    deviceVersion = androidInfo.version.release;
    Log.d('deviceVersion:$deviceVersion');
  } else if (isWindows()) {
    WindowsDeviceInfo windowsInfo = await deviceInfo.windowsInfo;
    deviceVersion = windowsInfo.productName;
    print('deviceVersion:$deviceVersion');
    if (deviceVersion.isEmpty) {
      deviceVersion = 'unknown';
    }
  }

  return deviceVersion;
}

/// 系统版本
Future<String> getDeviceId() async {
  DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
  String deviceId = '';
  if (isAndroid()) {
    AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
    deviceId = androidInfo.id;
    Log.d('deviceId:$deviceId');
  } else if (isWindows()) {
    WindowsDeviceInfo windowsInfo = await deviceInfo.windowsInfo;
    deviceId = windowsInfo.deviceId;
    print('deviceId:$deviceId');
  }

  return deviceId;
}
